<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24" type="flex" align="middle">
          <a-col flex="450px">
            <a-form-item label="">
              <a-input-group compact>
                <a-select v-model="queryParam.searchField" @change="changeForceUpdate" :dropdownMatchSelectWidth="false">
                  <a-select-option value="projectManager"> 项目经理 </a-select-option>
                  <a-select-option value="projectNo"> 项目编号 </a-select-option>
                  <a-select-option value="projectName"> 项目名称 </a-select-option>
                </a-select>
                <a-input-search
                  style="width: 78%"
                  v-model="queryParam.keyword"
                  @search="searchQuery"
                  placeholder="请按照关键字进行搜索"
                />
              </a-input-group>
            </a-form-item>
          </a-col>
          <a-col flex="auto">
            <span class="flex-btn-line">
              <a-button type="primary" @click="showSearchForm = true" icon="search">高级查询</a-button>
              <a-button
                type="primary"
                @click="handlePostExportXls('科技项目进度管理报表')"
                icon="download"
                >导出</a-button
              >
              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>

      <a-modal
        :visible="showSearchForm"
        width="70vw"
        :bodyStyle="{ padding: '10px' }"
        title="高级查询"
        @ok="handleToSearch"
        @cancel="showSearchForm = false"
      >
        <a-form-model ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol">
          <a-row :gutter="24">
            <a-col :span="8">
              <a-form-model-item label="项目经理">
                <a-input v-model="queryParam.projectManager" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目号">
                <a-input v-model="queryParam.projectNo" />
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="项目名称">
                <a-input v-model="queryParam.projectName" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-modal>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator"></div>
    <div class="container">
      <a-table
        ref="table"
        bordered
        size="middle"
        :scroll="{ x: true }"
        :rowKey="rowKey"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange, columnWidth: 40 }"
        :loading="loading"
        @change="handleTableChange"
      >
        <template slot="projectNo" slot-scope="text, record">
          <a @click="goProject(record)">{{ record.projectNo }}</a>
        </template>
        <template slot="projectChangeNo" slot-scope="text, record">
          <a @click="goProjectChange(record)">{{ record.projectChangeNo }}</a>
        </template>
        <template slot="changeReason" slot-scope="text, record">
          <span :title="record.changeReason">{{ showLength(record.changeReason, 15) }}</span>
        </template>
        <template slot="changeInfluence" slot-scope="text, record">
          <span :title="record.changeInfluence">{{ showLength(record.changeInfluence, 15) }}</span>
        </template>
        <template slot="projectDoneStatus" slot-scope="text, record">
          <span>{{ showProjectDoneStatus(record) }}</span>
        </template>
        
      </a-table>
    </div>
  </a-card>
</template>


<script>
import { JeecgListMixin } from '@/mixins/JeecgListSearchMixin'
export default {
  name: 'engineeProjectChangeList',
  mixins: [JeecgListMixin],
  data() {
    return {
      description: '科技项目进度管理报表',
      /* 勾选导出参数 */
      rowKey: 'id',
      busType: 'TechProjectProgressReport',
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 40,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
          fixed: 'left',
        },
        {
          title: '项目状态',
          align: 'center',
          width: 60,
          fixed: 'left',
          dataIndex: 'projectStatus',
        },
        {
          title: '项目编码',
          align: 'center',
          width: 80,
          fixed: 'left',
          dataIndex: 'projectNo',
        },
        {
          title: '项目名称',
          align: 'center',
          width: 120,
          fixed: 'left',
          dataIndex: 'projectName',
        },
        {
          title: '项目经理',
          align: 'center',
          width: 80,
          fixed: 'left',
          dataIndex: 'projectManager',
        },
        {
          title: '主导经营体',
          align: 'center',
          width: 120,
          fixed: 'left',
          dataIndex: 'mainDeptName',
        },
        {
          title: '高企',
          align: 'center',
          width: 30,
          dataIndex: 'isHeightTechProject',
        },
        {
          title: '费用支出公司',
          align: 'center',
          width: 100,
          dataIndex: 'factoryNames',
        },
        {
          title: '审批级别',
          align: 'center',
          width: 80,
          dataIndex: 'projectLevel',
        },
        {
          title: '项目预算',
          align: 'center',
          width: 80,
          dataIndex: 'budgetAmount',
        },
        {
          title: '核心成员人数',
          align: 'center',
          width: 60,
          dataIndex: 'memberNum',
        },
        {
          title: 'X绩点',
          align: 'center',
          width: 60,
          dataIndex: 'xPoint',
        },
        {
          title: 'Y绩点',
          align: 'center',
          width: 60,
          dataIndex: 'yPoint',
        },
        {
          title: '核心力值',
          align: 'center',
          width: 60,
          dataIndex: 'corePoint',
        },
        {
          title: '立项完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'projectBuildDate',
        },
        {
          title: '中期完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'midCompleteDate',
        },
        {
          title: '试产完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'trailProductDate',
        },
        {
          title: '上市计划完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'planPublicDate',
        },
        {
          title: '验收一计划完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'acceptOnePlanDate',
        },
        {
          title: '验收二计划完成时间',
          align: 'center',
          dataIndex: 'acceptTwoPlanDate',
          width: 100,
        },
        {
          title: '项目投产上市周期',
          align: 'center',
          width: 100,
          dataIndex: 'publicTime',
        },
        {
          title: '项目结题周期(天)',
          align: 'center',
          width: 60,
          dataIndex: 'acceptTwoTime',
        },
        {
          title: '剩余天数',
          align: 'center',
          width: 60,
          dataIndex: 'residueDays',
        },
        {
          title: '总节点数',
          align: 'center',
          width: 60,
          dataIndex: 'codeNodeNums',
        },
        {
          title: '已到期节点',
          align: 'center',
          width: 60,
          dataIndex: 'overdueNodeNums',
        },
        {
          title: '按时报工',
          align: 'center',
          width: 60,
          dataIndex: 'onTimeNodeNums',
        },
        {
          title: '逾期已报工',
          align: 'center',
          width: 60,
          dataIndex: 'overdueReportNodeNums',
        },
        {
          title: '逾期未报工',
          align: 'center',
          width: 60,
          dataIndex: 'overdueNotReportNodeNums',
        },
        {
          title: '未到期',
          align: 'center',
          width: 60,
          dataIndex: 'noOverdueNodeNums',
        },
        {
          title: '最大逾期天数',
          align: 'center',
          width: 60,
          dataIndex: 'maxOverdueDays',
        },
        {
          title: '及时率',
          align: 'center',
          width: 60,
          dataIndex: 'onTimeRate',
        },
        {
          title: '是否上市',
          align: 'center',
          width: 50,
          dataIndex: 'isPublic',
        },
        {
          title: '上市完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'planPublicNodeRealCompletionDate',
        },
        {
          title: '结题完成时间',
          align: 'center',
          width: 100,
          dataIndex: 'acceptTwoPlanRealCompletionDate',
        },
        {
          title: '转储时间',
          align: 'center',
          width: 100,
          dataIndex: 'reserveTime',
        },
        {
          title: '归档状态',
          align: 'center',
          width: 100,
          dataIndex: 'projectDoneStatus',
          scopedSlots: { customRender: 'projectDoneStatus' },
        },
        {
          title: '归档情况',
          align: 'center',
          width: 100,
          dataIndex: 'projectDoneMemo',
        },
      ],
      url: {
        list: '/projectReport/techProjectProgressReport',
        exportXlsUrl: '/projectReport/techProjectProgressReportExport',
      },
      showSearchForm: false,
      keyword: '',
      labelCol: { span: 8 },
      wrapperCol: { span: 15 },
      queryParam: {
        searchField: 'projectManager',
      },
    }
  },
  mounted() {},
  computed: {},
  methods: {
    goProject(record) {
      let urlJump = this.$router.resolve({ path: '/approval?projectBuildId=' + record.projectBuildId })
      window.open(urlJump.href, '_blank')
    },
    goProjectChange(record) {
      let urlJump = this.$router.resolve({ path:'/projectbuildstup/changeRecord?projectBuildId=' + record.projectBuildId + '&pageId=8&changeId=' + record.id })
      window.open(urlJump.href, '_blank')
    },
    handleToSearch() {
      this.showSearchForm = false
      this.searchQuery()
    },
    searchReset() {
      this.queryParam = {}
      this.queryParam.searchField = 'projectManager'
      this.handleToSearch()
    },
    showLength(item, len) {
      if (!item || item.length <= len) {
        return item
      }
      return item.substring(0, len) + '...'
    },
    showProjectDoneStatus(record) {
      if (!record.projectDoneMemo) {
        return '未完成'
      }

      if(['TA','TB','TC','TD'].includes(record.projectType) && record.projectDoneMemo == '一期验收;二期验收') {
        return '已完成'
      }

      if(['TE'].includes(record.projectType) && record.projectDoneMemo == 'TE项目验收') {
        return '已完成'
      }
      return '未完成'
    }
  },
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';
@import '~@assets/less/hte-main.less';
@media (max-width: 1170px) {
  .page-main .container section .list-content > div.flex-num1-box {
    flex-wrap: wrap;
    > div {
      &:nth-child(1),
      &:nth-child(2) {
        width: 48%;
      }
      &:nth-child(3) {
        width: 100%;
        justify-content: flex-start;
        > span {
          margin-right: 20px;
          margin-left: 0;
        }
      }
    }
  }
  .page-main .container section .list-content > div.flex-num2-box {
    display: block;
    margin-top: 0;
  }
}
</style>